<?php


//后台路由
//路由分层
Route::group(['prefix' => "admin", 'namespace' => 'Admin'], function () {
    Route::get("login", 'LoginController@index')->name('admin.login');
    Route::post("login", 'LoginController@login')->name('admin.login');
    Route::get('logout', 'LoginController@logout')->name('admin.logout');
    //使用中间件 验证是否登录
    Route::group(['middleware' => ['ckadmin'],'as'=>'admin.'], function () {
        //后台首页
        Route::get("getsysteminit", 'IndexController@getsysteminit')->name('getsysteminit');
        Route::get("index", 'IndexController@index')->name('index');
//        Route::get("welcome",'IndexController@welcome')->name('admin.welcome')->middleware(['ckadmin']);
        Route::get("welcome", 'IndexController@welcome')->name('welcome');
        //后台 用户管理 ------
        //发送邮件
//        Route::get('user/email',function (){
////            \Mail::raw("测试邮件！",function (\Illuminate\Mail\Message $message){
////                $message->to("1416075418@qq.com");
////                $message->subject("则是测试测试邮件");
////            });
//            //参数1 模板
//            //参数2 模板内容
//            \Mail::send('mail.adduser',['user'=>"张三"],function (\Illuminate\Mail\Message $message){
//                $message->to("1416075418@qq.com");
//                $message->subject("主题测试测试邮件");
//            });
//
//        });
        //上传文件
        //上传单个图片
        Route::post('upload/uploadimage','UploadController@uploadimage')->name('upload.image');

        //用户列表
        Route::get('user/index','UserController@index')->name('user.index');
        //用户添加 路由
        Route::get('user/add','UserController@create')->name('user.create');
        //用户添加操作
        Route::post('user/add','UserController@store')->name('user.store');
        //删除
        Route::delete('user/del/{id}','UserController@del')->name('user.del');
        //全选删除
        Route::delete('user/delall','UserController@delall')->name('user.delall');
        //修改用户
        Route::get('user/edit/{id}','UserController@edit')->name('user.edit');
        //修改用户处理
        Route::put('user/edit/{id}','UserController@update')->name('user.edit');
        //用户角色分配
        Route::match(['get','post'],'user/role/{id}','UserController@role')->name('user.role');
        //权限管理
        //资源路由 角色路由
        //角色权限
        Route::get('role/node/{role}','RoleController@node')->name('role.node');
        Route::post('role/nodesave/{role}','RoleController@nodesave')->name('role.nodesave');
        Route::resource('role','RoleController');
        //权限管理 节点
        Route::resource('node','NodeController');
        //生成es索引路由
        Route::get('article/es/init','ArticleController@esinit')->name('article.esinit');
        //文章导出
        Route::get('article/export','ArticleController@export')->name('article.export');
        //文章资源路由
        Route::resource("article",'ArticleController');
        //预约资源路由
        Route::resource("notice",'NoticeController');
        //用户接口资源路由
        Route::resource("apiuser",'ApiuserController');

    });

});
